package com.zzy.database.service.Impl;

import com.zzy.database.mapper.EmployeeMapper;
import com.zzy.database.pojo.Employee;
import com.zzy.database.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public void addEmployee(Employee employee) {
        employeeMapper.addEmployee(employee);
    }

    @Override
    public void deleteEmployee(String employeeId) {
        employeeMapper.deleteEmployeeById(employeeId);
    }
    @Override
    public void updateEmployee(Employee employee) {
        employeeMapper.updateEmployee(employee);
    }

    @Override
    public void assignEmployeeToBranch(String employeeId, String branchId) {
        employeeMapper.assignEmployeeToBranch(employeeId, branchId);
    }

    @Override
    public List<Employee> getEmployeesByBranchId(String branchId) {
        if(branchId == null){
            return employeeMapper.getAllEmployees();
        }
        return employeeMapper.getEmployeesByBranchId(branchId);
    }

    @Override
    public void complete(Employee employee) {
            employeeMapper.complete(employee);
        }

}



